<template>
    <div>
        <el-table :data="tableData" border stripe>
            <el-table-column type="index"></el-table-column>
            <el-table-column prop="code" label="编号" sortable></el-table-column>
            <el-table-column prop="price" label="价格" sortable></el-table-column>
            <el-table-column prop="volume" label="量" sortable></el-table-column>
            <el-table-column prop="amount" label="成交额" sortable></el-table-column>
            <el-table-column prop="dealPrice" label="成交价" sortable></el-table-column>
            <el-table-column prop="dealVolume" label="成交量" sortable></el-table-column>
            <el-table-column prop="command" label="方向" sortable>
                <template scope="scope">{{scope.row.command | dict('ENTRUST_COMMAND', $store.state.dict.list)}}
                </template>
            </el-table-column>
            <el-table-column prop="type" label="类型" sortable>
                <template scope="scope">{{scope.row.type | dict('ENTRUST_TYPE', $store.state.dict.list)}}</template>
            </el-table-column>
            <el-table-column prop="status" label="状态" sortable>
                <template scope="scope">{{scope.row.status | dict('ORDER_STATUS', $store.state.dict.list)}}</template>
            </el-table-column>
        </el-table>
        <div class="page fr">
            <el-pagination @size-change="handleSizeChange" @current-change="queryPage" :current-page="1"
                           :page-sizes="[10, 25, 50, 100]" :page-size="pageSize"
                           layout="total, sizes, prev, pager, next, jumper" :total="total"></el-pagination>
        </div>
    </div>
</template>
<script>
    import axios from '~plugins/axios';

    export default {
        data() {
            return {
                tableData: [],
                total: 0,
                pageSize: 10 // 每页条数
            };
        },
        methods: {
            handleSizeChange(val) {
                this.pageSize = val;
                this.queryPage(1);
            },
            queryPage(page) {
                axios.post(`/api/order/search/${(--page)}-${this.pageSize}/cd=0`, {
                    user: [`${this.$route.query.id}`]
                }).then(res => {
                    this.tableData = res.data['content'];
                    this.total = res.data['totalElements'];
                });
            }
        },
        mounted() {
            this.queryPage(1);
        }
    };
</script>